// package com.example.onlinemonitoring.comCenter;

// import com.example.onlinemonitoring.Util.CRC16;
// import com.example.onlinemonitoring.Util.CommPortManager;
// import com.example.onlinemonitoring.Util.HexUtil;
// import com.example.onlinemonitoring.model.Appdevice;
// import com.example.onlinemonitoring.model.Sctmhistory;
// import com.example.onlinemonitoring.model.Sctmsensor;
// import org.springframework.context.annotation.Scope;
// import com.example.onlinemonitoring.serviceImpl.SctmsensorServiceImpl;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.scheduling.annotation.Async;
// import org.springframework.stereotype.Service;

// import java.text.ParseException;
// import java.util.Date;

// /**
//  * 开关柜测温（闲业）
//  */
// @Service("sctmCom")
// @Scope("prototype")
// public class sctmCom extends CommPortManager {
//     public int nextstep; // 轮询阶段
//     public int splitstep = 0; // 数据分割阶段
//     @Autowired
//     private SctmsensorServiceImpl sctmserviceimpl;

//     @Override
//     public void receiveData(String str) {
//         setText(str);
//         if (!str.substring(2, 4).equals("03")) {
//             return;
//         }
//         String addrstr = str.substring(0, 2);
//         Integer addrint = parseHex4(addrstr);
//         setText("数据解析中...");
//         int start = 0;
//         int end = 0;
//         reSend[addrint] = 0;
//         if(splitstep == 1){
//             addrindex++;
//             start = 1;
//             end = 9;
//         }else if(splitstep == 2){
//             start = 10;
//             end = 17;
//         }
//         if (nextstep == 1) {// 解析温度数据
//             for (int i = start; i <= end; i++) {
//                 Sctmsensor sctm = new Sctmsensor();
//                 sctm.setStationid(ad.getStationid());
//                 sctm.setDevicegroup(ad.getDevicegroup());
//                 sctm.setDeviceaddr(addrint);
//                 sctm.setPointaddr(i);

//                 sctm.setLastacable(parseHex4(str.substring((i - start) * 36 + 6, (i - start) * 36 + 10)) * 0.1f);
//                 sctm.setLastbcable(parseHex4(str.substring((i - start) * 36 + 10, (i - start) * 36 + 14)) * 0.1f);
//                 sctm.setLastccable(parseHex4(str.substring((i - start) * 36 + 14, (i - start) * 36 + 18)) * 0.1f);
//                 sctm.setLastaupcontact(parseHex4(str.substring((i - start) * 36 + 18, (i - start) * 36 + 22)) * 0.1f);
//                 sctm.setLastbupcontact(parseHex4(str.substring((i - start) * 36 + 22, (i - start) * 36 + 26)) * 0.1f);
//                 sctm.setLastcupcontact(parseHex4(str.substring((i - start) * 36 + 26, (i - start) * 36 + 30)) * 0.1f);
//                 sctm.setLastalowcontact(parseHex4(str.substring((i - start) * 36 + 30, (i - start) * 36 + 34)) * 0.1f);
//                 sctm.setLastblowcontact(parseHex4(str.substring((i - start) * 36 + 34, (i - start) * 36 + 38)) * 0.1f);
//                 sctm.setLastclowcontact(parseHex4(str.substring((i - start) * 36 + 38, (i - start) * 36 + 42)) * 0.1f);
//                 if (validate(sctm.getLastacable()) || validate(sctm.getLastbcable()) || validate(sctm.getLastccable())
//                         || validate(sctm.getLastaupcontact()) || validate(sctm.getLastbupcontact())
//                         || validate(sctm.getLastcupcontact())
//                         || validate(sctm.getLastalowcontact()) || validate(sctm.getLastblowcontact())
//                         || validate(sctm.getLastclowcontact())) {
//                     return;
//                 }
//                 Sctmsensor alarm = sctmserviceimpl.getModel(sctm);
//                 if (alarm == null) {
//                     continue;
//                 }

//                 sctm.setLastacablealarmstatus(GetAlarmStatus(isnull(sctm.getLastacable()),
//                         isnull(alarm.getAcablealarmvalue()),
//                         isnull(alarm.getAcablealarmrelievevalue()), isnull(alarm.getAcablewarnvalue()),
//                         isnull(alarm.getAcablewarnrelievevalue()),
//                         isnull(alarm.getLastacablealarmstatus()), true, "A相电缆温度",alarm.getDevicegroup(), addrint, alarm.getPointname(), i));

//                 sctm.setLastbcablealarmstatus(GetAlarmStatus(isnull(sctm.getLastbcable()),
//                         isnull(alarm.getBcablealarmvalue()),
//                         isnull(alarm.getBcablealarmrelievevalue()), isnull(alarm.getBcablewarnvalue()),
//                         isnull(alarm.getBcablewarnrelievevalue()),
//                         isnull(alarm.getLastbcablealarmstatus()), true, "B相电缆温度",alarm.getDevicegroup(), addrint, alarm.getPointname(), i));

//                 sctm.setLastccablealarmstatus(GetAlarmStatus(isnull(sctm.getLastccable()),
//                         isnull(alarm.getCcablealarmvalue()),
//                         isnull(alarm.getCcablealarmrelievevalue()), isnull(alarm.getCcablewarnvalue()),
//                         isnull(alarm.getCcablewarnrelievevalue()),
//                         isnull(alarm.getLastccablealarmstatus()), true, "C相电缆温度",alarm.getDevicegroup(), addrint, alarm.getPointname(), i));

//                 sctm.setLastaupcontactalarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastaupcontact()),
//                         HexUtil.isnull(alarm.getAupcontactalarmvalue()),
//                         HexUtil.isnull(alarm.getAupcontactalarmrelievevalue()),
//                         HexUtil.isnull(alarm.getAupcontactwarnvalue()),
//                         HexUtil.isnull(alarm.getAupcontactwarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastaupcontactalarmstatus()), true, "上触头A相温度",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastbupcontactalarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbupcontact()),
//                         HexUtil.isnull(alarm.getBupcontactalarmvalue()),
//                         HexUtil.isnull(alarm.getBupcontactalarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBupcontactwarnvalue()),
//                         HexUtil.isnull(alarm.getBupcontactwarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbupcontactalarmstatus()), true, "上触头B相温度",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastcupcontactalarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastcupcontact()),
//                         HexUtil.isnull(alarm.getCupcontactalarmvalue()),
//                         HexUtil.isnull(alarm.getCupcontactalarmrelievevalue()),
//                         HexUtil.isnull(alarm.getCupcontactwarnvalue()),
//                         HexUtil.isnull(alarm.getCupcontactwarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastcupcontactalarmstatus()), true, "上触头C相温度",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastalowcontactalarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastalowcontact()),
//                         HexUtil.isnull(alarm.getAlowcontactalarmvalue()),
//                         HexUtil.isnull(alarm.getAlowcontactalarmrelievevalue()),
//                         HexUtil.isnull(alarm.getAlowcontactwarnvalue()),
//                         HexUtil.isnull(alarm.getAlowcontactwarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastalowcontactalarmstatus()), true, "下触头A相温度",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastblowcontactalarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastblowcontact()),
//                         HexUtil.isnull(alarm.getBlowcontactalarmvalue()),
//                         HexUtil.isnull(alarm.getBlowcontactalarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBlowcontactwarnvalue()),
//                         HexUtil.isnull(alarm.getBlowcontactwarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastblowcontactalarmstatus()), true, "下触头B相温度",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastclowcontactalarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastclowcontact()),
//                         HexUtil.isnull(alarm.getClowcontactalarmvalue()),
//                         HexUtil.isnull(alarm.getClowcontactalarmrelievevalue()),
//                         HexUtil.isnull(alarm.getClowcontactwarnvalue()),
//                         HexUtil.isnull(alarm.getClowcontactwarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastclowcontactalarmstatus()), true, "下触头C相温度",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));
//                 sctm.setLastdatatimexj(new Date());

//                 sctm.setLastdatatime(new Date());
//                 String alarmMessage = "";
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastaupcontactalarmstatus()), " 上触头A相温度");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbupcontactalarmstatus()), " 上触头B相温度");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastcupcontactalarmstatus()), " 上触头C相温度");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastalowcontactalarmstatus()), "下触头A相温度");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastblowcontactalarmstatus()), "下触头B相温度");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastclowcontactalarmstatus()), "下触头C相温度");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastacablealarmstatus()), "     A相电缆温度  ");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbcablealarmstatus()), "     B相电缆温度  ");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastccablealarmstatus()), "     C相电缆温度  ");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbatteryvoltage1alarmstatus()), "上触头A相电池电压");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbatteryvoltage2alarmstatus()), "上触头B相电池电压");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbatteryvoltage3alarmstatus()), "上触头C相电池电压");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbatteryvoltage4alarmstatus()), "下触头A相电池电压");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbatteryvoltage5alarmstatus()), "下触头B相电池电压");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbatteryvoltage6alarmstatus()), "下触头C相电池电压");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbatteryvoltage7alarmstatus()), "A相电缆电池电压");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbatteryvoltage8alarmstatus()), "B相电缆电池电压");
//                 alarmMessage += GetAlarmMessage(isnull(alarm.getLastbatteryvoltage9alarmstatus()), "C相电缆电池电压");
//                 sctm.setLastalarmlevel(HexUtil.MAX(new int[] { isnull(alarm.getLastaupcontactalarmstatus()),
//                         isnull(alarm.getLastbupcontactalarmstatus()), isnull(alarm.getLastcupcontactalarmstatus()),
//                         isnull(alarm.getLastalowcontactalarmstatus()), isnull(alarm.getLastblowcontactalarmstatus()),
//                         isnull(alarm.getLastclowcontactalarmstatus()), isnull(alarm.getLastacablealarmstatus()),
//                         isnull(alarm.getLastbcablealarmstatus()), isnull(alarm.getLastccablealarmstatus()),
//                         isnull(alarm.getLastbatteryvoltage1alarmstatus()),
//                         isnull(alarm.getLastbatteryvoltage2alarmstatus()),
//                         isnull(alarm.getLastbatteryvoltage3alarmstatus()),
//                         isnull(alarm.getLastbatteryvoltage4alarmstatus()),
//                         isnull(alarm.getLastbatteryvoltage5alarmstatus()),
//                         isnull(alarm.getLastbatteryvoltage6alarmstatus()),
//                         isnull(alarm.getLastbatteryvoltage7alarmstatus()),
//                         isnull(alarm.getLastbatteryvoltage8alarmstatus()),
//                         isnull(alarm.getLastbatteryvoltage9alarmstatus()) }));
//                 sctm.setLastalarmmessage(alarmMessage);
//                 sctm.setLastcommunicationstatus(0);
//                 sctm.setLasthisdatatime(addHistory(sctmserviceimpl.getModel(sctm)));
//                 sctmserviceimpl.Update(sctm, false);
//             }
//             if(splitstep == 1){
//                 String cstr = String.format("%s03", HexUtil.intToHexString(addrint, 1));
//                 cstr += "062E";
//                 cstr += "0048";
//                 cstr += CRC16.calcCrc16(cstr);
//                 try {
//                     setText("请求第二包数据"+cstr);
//                     Send(cstr);
//                 } catch (Exception EX) {
//                     setText(EX.toString());
//                 }
//                 splitstep = 2;
//             }
//         } else {// 解析电池电压数据
//             for (int i = start; i <= end; i++) {
//                 Sctmsensor sctm = new Sctmsensor();
//                 sctm.setStationid(ad.getStationid());
//                 sctm.setDevicegroup(ad.getDevicegroup());
//                 sctm.setDeviceaddr(addrint);
//                 sctm.setPointaddr(i);
//                 sctm.setLastbatteryvoltage1(parseHex4(str.substring((i - start) * 36 + 6, (i - start) * 36 + 10)));
//                 sctm.setLastbatteryvoltage2(parseHex4(str.substring((i - start) * 36 + 10, (i - start) * 36 + 14)));
//                 sctm.setLastbatteryvoltage3(parseHex4(str.substring((i - start) * 36 + 14, (i - start) * 36 + 18)));
//                 sctm.setLastbatteryvoltage4(parseHex4(str.substring((i - start) * 36 + 18, (i - start) * 36 + 22)));
//                 sctm.setLastbatteryvoltage5(parseHex4(str.substring((i - start) * 36 + 22, (i - start) * 36 + 26)));
//                 sctm.setLastbatteryvoltage6(parseHex4(str.substring((i - start) * 36 + 26, (i - start) * 36 + 30)));
//                 sctm.setLastbatteryvoltage7(parseHex4(str.substring((i - start) * 36 + 30, (i - start) * 36 + 34)));
//                 sctm.setLastbatteryvoltage8(parseHex4(str.substring((i - start) * 36 + 34, (i - start) * 36 + 38)));
//                 sctm.setLastbatteryvoltage9(parseHex4(str.substring((i - start) * 36 + 38, (i - start) * 36 + 42)));
//                 if (sctm.getLastbatteryvoltage1() == 0 && sctm.getLastbatteryvoltage2() == 0
//                         && sctm.getLastbatteryvoltage3() == 0
//                         && sctm.getLastbatteryvoltage4() == 0 && sctm.getLastbatteryvoltage5() == 0
//                         && sctm.getLastbatteryvoltage6() == 0
//                         && sctm.getLastbatteryvoltage7() == 0 && sctm.getLastbatteryvoltage8() == 0
//                         && sctm.getLastbatteryvoltage9() == 0) {
//                     continue;
//                 }
//                 Sctmsensor alarm = sctmserviceimpl.getModel(sctm);
//                 if (alarm == null) {
//                     continue;
//                 }
//                 sctm.setLastbatteryvoltage1alarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbatteryvoltage1()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbatteryvoltage7alarmstatus()), false, "上触头A相电池电压",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastbatteryvoltage2alarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbatteryvoltage2()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbatteryvoltage8alarmstatus()), false, "上触头B相电池电压",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastbatteryvoltage3alarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbatteryvoltage3()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbatteryvoltage9alarmstatus()), false, "上触头C相电池电压",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastbatteryvoltage4alarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbatteryvoltage4()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbatteryvoltage7alarmstatus()), false, "下触头A相电池电压",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastbatteryvoltage5alarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbatteryvoltage5()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbatteryvoltage8alarmstatus()), false, "下触头B相电池电压",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastbatteryvoltage6alarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbatteryvoltage6()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbatteryvoltage9alarmstatus()), false, "下触头C相电池电压",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastbatteryvoltage7alarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbatteryvoltage7()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbatteryvoltage7alarmstatus()), false, "A相电缆电池电压",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastbatteryvoltage8alarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbatteryvoltage8()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbatteryvoltage8alarmstatus()), false, "B相电缆电池电压",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctm.setLastbatteryvoltage9alarmstatus(GetAlarmStatus(HexUtil.isnull(sctm.getLastbatteryvoltage9()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagealarmrelievevalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnvalue()),
//                         HexUtil.isnull(alarm.getBatteryvoltagewarnrelievevalue()),
//                         HexUtil.isnull(alarm.getLastbatteryvoltage9alarmstatus()), false, "C相电缆电池电压",alarm.getDevicegroup(), addrint,
//                         alarm.getPointname(), i));

//                 sctmserviceimpl.Update(sctm, false);
//             }
//             if(splitstep == 1){
//                 String cstr = String.format("%s03", HexUtil.intToHexString(addrint, 1));
//                 cstr += "0A16";
//                 cstr += "0048";
//                 cstr += CRC16.calcCrc16(cstr);
//                 try {
//                     setText("请求第二包数据"+cstr);
//                     Send(cstr);
//                 } catch (Exception EX) {
//                     setText(EX.toString());
//                 }
//                 splitstep = 2;
//             }
//         }
//         setText("数据解析完毕！");
//     }

//     private Date addHistory(Sctmsensor sensor) {
//         if (sensor != null) {
//             if (sensor.getLasthisdatatime() == null) {
//                 add(sensor);
//                 return new Date();
//             } else {
//                 long lasttime = 0;
//                 long nowtime = 0;
//                 try {
//                     lasttime = HexUtil.todate(sensor.getLasthisdatatime()).getTime();
//                     nowtime = HexUtil.todate(new Date()).getTime();
//                 } catch (ParseException e) {
//                     e.printStackTrace();
//                 }
//                 int timersp = 60000;
//                 if (sensor.getLastalarmlevel() != 0) {
//                     timersp = ad.getHisalarmtimersp() * 1000;
//                 } else {
//                     timersp = ad.getHistimersp() * 1000;
//                 }
//                 if (lasttime + timersp < nowtime) {
//                     add(sensor);
//                     return new Date();
//                 }
//             }
//         }
//         return null;
//     }

//     private void add(Sctmsensor sensor) {
//         Sctmhistory his = new Sctmhistory();
//         his.setStationid(sensor.getStationid());
//         his.setDevicegroup(sensor.getDevicegroup());
//         his.setDeviceaddr(sensor.getDeviceaddr());
//         his.setPointaddr(sensor.getPointaddr());
//         his.setAddrname(sensor.getAddrname());
//         his.setPointname(sensor.getPointname());
//         his.setDatatime(sensor.getLastdatatime());
//         his.setAupcontact(sensor.getLastaupcontact());
//         his.setBupcontact(sensor.getLastbupcontact());
//         his.setCupcontact(sensor.getLastcupcontact());
//         his.setAlowcontact(sensor.getLastalowcontact());
//         his.setBlowcontact(sensor.getLastblowcontact());
//         his.setClowcontact(sensor.getLastclowcontact());
//         his.setAcable(sensor.getLastacable());
//         his.setBcable(sensor.getLastbcable());
//         his.setCcable(sensor.getLastccable());
//         his.setAlarmlevel(sensor.getLastalarmlevel());
//         his.setAlarmmessage(sensor.getLastalarmmessage());
//         his.setAupcontactalarmstatus(sensor.getLastaupcontactalarmstatus());
//         his.setBupcontactalarmstatus(sensor.getLastbupcontactalarmstatus());
//         his.setCupcontactalarmstatus(sensor.getLastcupcontactalarmstatus());
//         his.setAlowcontactalarmstatus(sensor.getLastalowcontactalarmstatus());
//         his.setBlowcontactalarmstatus(sensor.getLastblowcontactalarmstatus());
//         his.setClowcontactalarmstatus(sensor.getLastclowcontactalarmstatus());
//         his.setAcablealarmstatus(sensor.getLastacablealarmstatus());
//         his.setBcablealarmstatus(sensor.getLastbcablealarmstatus());
//         his.setCcablealarmstatus(sensor.getLastccablealarmstatus());
//         his.setAspare(sensor.getLastaspare());
//         his.setBspare(sensor.getLastbspare());
//         his.setCspare(sensor.getLastcspare());
//         his.setMemo(sensor.getMemo());
//         his.setInuse(sensor.getInuse());
//         his.setStyle(sensor.getStyle());
//         his.setAsparealarmstatus(sensor.getLastasparealarmstatus());
//         his.setBsparealarmstatus(sensor.getLastbsparealarmstatus());
//         his.setCsparealarmstatus(sensor.getLastcsparealarmstatus());
//         his.setBatteryvoltage1(sensor.getLastbatteryvoltage1());
//         his.setBatteryvoltage2(sensor.getLastbatteryvoltage2());
//         his.setBatteryvoltage3(sensor.getLastbatteryvoltage3());
//         his.setBatteryvoltage4(sensor.getLastbatteryvoltage4());
//         his.setBatteryvoltage5(sensor.getLastbatteryvoltage5());
//         his.setBatteryvoltage6(sensor.getLastbatteryvoltage6());
//         his.setBatteryvoltage7(sensor.getLastbatteryvoltage7());
//         his.setBatteryvoltage8(sensor.getLastbatteryvoltage8());
//         his.setBatteryvoltage9(sensor.getLastbatteryvoltage9());
//         his.setBatteryvoltage1alarmstatus(sensor.getLastbatteryvoltage1alarmstatus());
//         his.setBatteryvoltage2alarmstatus(sensor.getLastbatteryvoltage2alarmstatus());
//         his.setBatteryvoltage3alarmstatus(sensor.getLastbatteryvoltage3alarmstatus());
//         his.setBatteryvoltage4alarmstatus(sensor.getLastbatteryvoltage4alarmstatus());
//         his.setBatteryvoltage5alarmstatus(sensor.getLastbatteryvoltage5alarmstatus());
//         his.setBatteryvoltage6alarmstatus(sensor.getLastbatteryvoltage6alarmstatus());
//         his.setBatteryvoltage7alarmstatus(sensor.getLastbatteryvoltage7alarmstatus());
//         his.setBatteryvoltage8alarmstatus(sensor.getLastbatteryvoltage8alarmstatus());
//         his.setBatteryvoltage9alarmstatus(sensor.getLastbatteryvoltage9alarmstatus());
//         sctmserviceimpl.Add(his);
//     }

//     boolean validate(float value) {
//         if (value > 1000) {
//             return true;
//         } else {
//             return false;
//         }
//     }

//     @Async("threadPool")
//     public void startSendThread(Appdevice Appdevice) throws Exception {

//         checkType = "crc16";
//         issend.put(Thread.currentThread().getId(), true);
//         String cstr = "";
//         String cmdtype = "05DD";
//         String nametype = "温度";
//         int timersp = (int) Math.round(Appdevice.getTimersp() * 1000);
//         while (issend.get(Thread.currentThread().getId()) != null) {
//             if (isrun) {
//                 splitstep = 1;
//                 if (addrindex > Appdevice.getAddrmax() || addrindex < Appdevice.getAddrmin()) {
//                     if (nextstep == 0) {
//                         setText("【=============准备开始温度数据采集=============】");
//                         cmdtype = "05DD";
//                         nametype = "温度";
//                         nextstep = 1;
//                     } else {
//                         setText("【=============准备开始电池电压数据采集=============】");
//                         cmdtype = "09C5";
//                         nametype = "电池电压";
//                         nextstep = 0;
//                     }
//                     setText("倒计时6秒...");
//                     Thread.sleep(1000);
//                     setText("倒计时5秒...");
//                     Thread.sleep(1000);
//                     setText("倒计时4秒...");
//                     Thread.sleep(1000);
//                     setText("倒计时3秒...");
//                     Thread.sleep(1000);
//                     setText("倒计时2秒...");
//                     Thread.sleep(1000);
//                     setText("倒计时1秒...");
//                     Thread.sleep(1000);
//                     addrindex = Appdevice.getAddrmin();
//                 }
//                 cstr = String.format("%s03", HexUtil.intToHexString(addrindex, 1));
//                 cstr += cmdtype;
//                 cstr += "0069";
//                 cstr += CRC16.calcCrc16(cstr);
//                 try {
//                     Send(cstr);
//                 } catch (Exception EX) {
//                     setText(EX.toString());
//                 }
//                 setText("向" + Appdevice.getName() + "设备发送采集" + nametype + "指令" + cstr);
//                 reSend[addrindex]++;
//                 if (reSend[addrindex] > 3) {
//                     sctmserviceimpl.UpdateStatus(ad, addrindex, 1);
//                     reSend[addrindex] = 0;
//                     addrindex++;
//                 }
//             } else if (rescode != 0) {
//                 setText(resmsg[rescode]);
//             }
//             Thread.sleep(timersp);
//         }
//     }
// }
